package de.tabuma.shopping.entity;

import java.util.*;
import javax.jdo.annotations.*;

/**
 * 
 * @author $Author: alefen $
 * @version $Revision: 1.1 $
 * @since $Date: 2009/07/21 19:37:33 $
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class License {

    private static Integer counter = new Integer(0);

    public License() {
        counter++;
        this.id = counter.longValue();
        this.count = 0;
        this.licenseTyp = 0;
        this.licenseMode = 0;
    }
    
    public License(int count, int licenseTyp, int licenseMode) {
        counter++;
        this.id = counter.longValue();
        this.count = count;
        this.licenseTyp = licenseTyp;
        this.licenseMode = licenseMode;
    }

    public License(int id, int count, int licenseTyp, int licenseMode) {
        this.id = (long) id;
        this.count = count;
        this.licenseTyp = licenseTyp;
        this.licenseMode = licenseMode;
    }

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    public Long getId() {
        return id;
    }

    @Persistent
    private int licenseTyp;
    public int getLicenseTyp() {
        return licenseTyp;
    }
    public void setLicenseTyp(int licenseTyp) {
        this.licenseTyp = licenseTyp;
    }

    @Persistent
    private int count;
    public int getCount() {
        return count;
    }
    public void setCount(int count) {
        this.count = count;
    }

    @Persistent
    private int licenseMode;

    public int getLicenseMode() {
        return licenseMode;
    }
    public void setLicenseMode(int licenseMode) {
        this.licenseMode = licenseMode;
    }
    
    public boolean isBoughtLicense() {
        if(this.licenseMode==1) {
            return true;
        }
        return false;
    }

    public boolean isUsedLicense() {
        if(this.licenseMode==2) {
            return true;
        }
        return false;
    }
}
